package bawei.com.bilibili;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

/**
 * 作者：张宏达
 * 类的创建时间： 2017/3/22 18:06
 * 类的作用：登陆界面
 */

public class LoginActivity extends Activity implements View.OnClickListener {

    ImageView iv_login_left;
    ImageView iv_login_right;
    EditText ed_login_username;
    EditText ed_login_password;
    Button bt_login_register;
    Button bt_login_login;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        initView();
    }

    private void initView() {

        iv_login_left = (ImageView) findViewById(R.id.iv_login_left);
        iv_login_right = (ImageView) findViewById(R.id.iv_login_right);
        ed_login_username = (EditText) findViewById(R.id.ed_login_username);
        ed_login_password = (EditText) findViewById(R.id.ed_login_password);
        bt_login_register = (Button) findViewById(R.id.bt_login_register);
        bt_login_login = (Button) findViewById(R.id.bt_login_login);

        ed_login_username.setOnClickListener(this);
        ed_login_password.setOnClickListener(this);
        bt_login_register.setOnClickListener(this);
        bt_login_login.setOnClickListener(this);

        ed_login_username.setFocusable(false);
        ed_login_password.setFocusable(false);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ed_login_username:

                iv_login_left.setImageResource(R.drawable.ic_22);
                iv_login_right.setImageResource(R.drawable.ic_33);
                editText(ed_login_password, ed_login_username);
                break;
            case R.id.ed_login_password:

                iv_login_left.setImageResource(R.drawable.ic_22_hide);
                iv_login_right.setImageResource(R.drawable.ic_33_hide);
                editText(ed_login_username, ed_login_password);
                break;
            case R.id.bt_login_register:
                break;
            case R.id.bt_login_login:
                break;
        }
    }

    public void editText(EditText STAONE, EditText STATWO) {

        STAONE.setFocusable(false);
        STATWO.setFocusable(true);
        STATWO.setFocusableInTouchMode(true);
        STATWO.requestFocus();
        STATWO.requestFocusFromTouch();
        InputMethodManager inputManagerright =
                (InputMethodManager) STATWO.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManagerright.showSoftInput(STATWO, 0);
    }

}

